package thoughtworks.test;

/*
 * This class is used to convert a number to roman letter
 */
public class NumberToRomanConversion {
	public String convertNumberToRoman(String num) throws InvalidNumberException{
		StringBuilder text = new StringBuilder();
		int number = 0;
		try{
			number = Integer.valueOf(num);
		}
		catch(Exception e){
			throw new InvalidNumberException("INVALID NUMBER.");
		}
		if(number >0 && number < 4000){
			for(int i =0; i<13; i++){
				while(number >= ConstantsUtil.numbers[i]){
					number -= ConstantsUtil.numbers[i];
					text.append(ConstantsUtil.romanNo[i]);
				}
			}
		} else {
			throw new InvalidNumberException("INVALID NUMBER.");
		}
		return text.toString();
	}

}
